<?php
declare (strict_types = 1);

namespace app\middleware;
use app\BaseController;
use think\facade\Session;
use think\facade\View;

use app\model\Node as ND;

class NavCheck
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        $node_list = ND::where('node_grade',"1")->select();

        foreach ($node_list as $k=>$v){
            $node = ND::where('node_grade',"2")->where('node_partent',$v['id'])->select();
            $node_list[$k]['node'] = $node;
        }
        $user = Session::get('admin');
        View::assign('node_list',$node_list);
        View::assign('user',$user);
        return $next($request);
    }
}
